package com.qfedu.controller;


import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName BaseController
 * @Description TODO
 * @Author young
 * @Date 2022-09-21 19:34
 * @Version 1.0
 **/
@RestController
@RequestMapping("/base")
public class BaseController {

    @Autowired
    UploadUtils uploadUtils;

    //上传
    @PostMapping("/upload")
    public BaseResp upload(@RequestParam("file")MultipartFile multipartFile){
        String upload = uploadUtils.upload(multipartFile);
        if (StringUtils.isEmpty(upload)) {
            return new BaseResp().Error();
        }
        return new BaseResp(1,"success",upload,null);
    }
}
